home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 8 / Mac Magazin and MacEasy Magazine CD - Issue 08.iso / Sharewarebibliothek / Updater⁄Infos / Frontier 2.0 => 2.0.1 Upgrader / Install Files / DocServer Docs / local < prev    next >
Text File  |  1993-02-25  |  2KB  |  29 lines

  1.  
  2. Verb    local
  3. Syntax    local
  4.     identifier1 [ = expression1]
  5.     identifier2 [ = expression2]
  6.     ...
  7.     identifierN [ = expressionN]
  8. or
  9. local (identifier1 [ = expression1], ..., identifierN [ = expressionN])
  10. Action    Creates local variables named identifier1 through identifierN, assigning the initial values that are the result of evaluating expressions 1 through N where provided.
  11. The scope of the variables is limited to the statements following the local statement, in the same block of code. That is, the definition does not persist past the last statement in the current if, while, loop, for, fileloop, on, with, bundle, case, or else statement body.
  12. Examples    local (x = 1)
  13. if file.isFolder (path)
  14.     local (x)
  15.     x = file.byteInFolder (path) « this "x" is private
  16.     msg (string.kBytes (x))
  17. else
  18.     local (x = file.size (path)) « this "x" is private
  19.     msg (string.kBytes (x))
  20. msg (x) « "x" from first line is still 1
  21. (Do not attempt to execute this script outside a script window.) This example, while not recommended programming style, illustrates how the scope of a local variable is limited to the statements following it in the current body of the containing structural statement.
  22. Notes    • The local statement does not have to appear as the first statement in a block of code. If it appears in the middle of a block, its scope excludes the statements that appear above it.
  23. • When an assignment is made to a variable that hasn’t been defined, a new local variable is created in the code block where a local statement or a local script definition was most recently encountered.
  24. • UserTalk is a “dynamically scoped” language. That means that local variables can be “seen” by scripts called from a statement in the statement block, as long as both scripts are in the same script object.
  25. • Local variables are database objects, just like other values that you work with in tables. As such, you can take their address with the address operator, and use that address in any context where an object database address is called for.
  26. See Also    =
  27. @
  28. on
  29.